package com.crawler.harbour.model;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import com.crawler.harbour.common.DockCode;
import com.crawler.harbour.dto.Fee;

public class GGHGbiaozhun {

    private String ladingBillNo;
    private String containerNo;
    private String id;
    private String totalFee;
    private String portNo = DockCode._HC;
    private String storageDays;
    private String result;
    private String outTime;
    private List<Fee> feeList=new ArrayList<Fee>();

    public String getOutTime() {
		return outTime;
	}

	public void setOutTime(String outTime) {
		this.outTime = outTime;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getLadingBillNo() {
		return ladingBillNo;
	}

	public void setLadingBillNo(String ladingBillNo) {
		this.ladingBillNo = ladingBillNo;
	}

	public String getContainerNo() {
		return containerNo;
	}

	public void setContainerNo(String containerNo) {
		this.containerNo = containerNo;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getStorageDays() {
		return storageDays;
	}

	public void setStorageDays(String storageDays) {
		this.storageDays = storageDays;
	}

    public String getTotalFee() {
        return totalFee;
    }

    public void setTotalFee(String totalFee) {
        this.totalFee = totalFee;
    }
    
    public String getPortNo() {
		return portNo;
	}

	public void setPortNo(String portNo) {
		this.portNo = portNo;
	}

    public List<Fee> getFeeList() {
		return feeList;
	}

	public void setFeeList(List<Fee> feeList) {
		this.feeList = feeList;
	}

	DecimalFormat df = new DecimalFormat("0.###");
	public void addFee(String feeCode,String feeValue) {
		
		
		if(feeValue!=null&&feeValue.trim().length()!=0&&!feeValue.trim().equals("0")&&feeValue.trim().matches("^\\d+(\\.\\d+)?$")) {
			BigDecimal fee = new BigDecimal(feeValue.trim());
			
			for(Fee originalFee:feeList) {
				if(originalFee.getCostCode().equals(feeCode)) {
					BigDecimal newFee = new BigDecimal(df.format(originalFee.getFee())).add(fee);
					originalFee.setFee(newFee.doubleValue());
					return;
				}
			}
			
			this.feeList.add(new Fee(feeCode, Double.valueOf(feeValue.trim())));
						
		}
	}
}
